import {url} from './index';
import axios from 'axios';


export const  getCommodity = async (params) => {
    let result = await axios({
        method:'get',
        url:url+'/commodity',
        params
    })
    return result.data;
}
export const  getCommodityById = async (_id) => {
    let result = await axios({
        method:'get',
        url:url+'/commodity/'+_id,
        params:{}
    })
    return result.data;
}

export const  deleteCommodity = async (_id) => {
    let result = await axios({
        method:'delete',
        url:url+'/commodity/'+_id,
    })
    return result.data;
}
export const  addCommodity = async (data) => {
    let result = await axios({
        method:'post',
        url:url+'/commodity',
        data
    })
    return result.data;
}

// 搜索参数{type,value}
export const  searchCommodity = async (data) => {
    let result = await axios({
        method:'get',
        url:url+'/commodity',
        params:data
    })
    return result.data;
}

export const  updateCommodity = async (data) => {
    let result = await axios({
        method:'put',
        url:url+`/commodity/${data._id}`,
        data
    })
    return result.data;
}
